** SavunTironeAJPS
 use "Savun-Tirone 2011 AJPS Replication Dataset.dta", clear

 gen ccode =  recipient_cowcode
drop if  recipient_cowcode==.
 sort ccode year
merge m:1 ccode using gattlist.dta 
drop if _m==2 
drop _merge
sort ccode year
merge m:1 ccode using wtolist.dta 
drop if _m==2 
drop _merge

gen gatt = year>=gattjoin
gen wto = year>=wtojoin
gen gattwto = gatt==1 | wto==1
gen study = ""
foreach n in orig noth fe time fet ct yfe cyfe {
gen method_`n' = ""
gen dv_`n' = ""
gen b_gatt_`n' = .
gen se_gatt_`n'= .
gen pval_gatt_`n' = .
gen lo_gatt_`n'=.
gen hi_gatt_`n'=.
gen N_gatt_`n'=.
}
gen studynum=.
gen timetrend=""
qui do gatt.do
local ii = 1
tsset recipient_cowcode year
gen fconflict_initition = f.conflict_initiation
*model 1
logit f.conflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear peace_years peaceyears_spline1 peaceyears_spline2 peaceyears_spline3 if polity2006!=-66&polity2006!=-77&year>=1990, vce(cluster recipient_cowcode)
gatt `ii' orig
logit f.conflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  if polity2006!=-66&polity2006!=-77&year>=1990, vce(cluster recipient_cowcode)
gatt `ii' noth
xtlogit f.conflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  if polity2006!=-66&polity2006!=-77&year>=1990, fe
gatt `ii' fe
logit f.conflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear peace_years peaceyears_spline1 peaceyears_spline2 peaceyears_spline3 if polity2006!=-66&polity2006!=-77&year>=1990, vce(cluster recipient_cowcode)
gatt `ii' time
xtlogit f.conflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear peace_years peaceyears_spline1 peaceyears_spline2 peaceyears_spline3 if polity2006!=-66&polity2006!=-77&year>=1990, fe
gatt `ii' fet
logit f.conflict_initiation i.ccode#c.year gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear peace_years peaceyears_spline1 peaceyears_spline2 peaceyears_spline3 if polity2006!=-66&polity2006!=-77&year>=1990, vce(cluster recipient_cowcode)
gatt `ii' ct
xtreg f.conflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear i.year if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(cluster recipient_cowcode)
gatt `ii' cyfe
clogit fconflict_initiation gattwto democracy_aid democracyaidXdemocratization democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  if polity2006!=-66&polity2006!=-77&year>=1990, group(year) vce(cluster year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'  
replace timetrend="splines" if _n==`ii' 
local ii=`ii'+1
***Table 2***
**Models 2-3**
*ivreg*
*model 2
ivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US)
gatt `ii' orig
ivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US)
gatt `ii' noth
xtivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US) fe
gatt `ii' fe
ivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear year (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US)
gatt `ii' time
*xtivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear year (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US) fe
*gatt `ii' fet
preserve
tab ccode , gen(_i)
foreach v of varlist _i* {
replace `v' = `v'*year
}
ivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear _i* (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US)
restore
gatt `ii' ct
preserve
tab ccode , gen(_i)

xtivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear _i* (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US) fe
restore
gatt `ii' cyfe
/*preserve
tab year , gen(_i)
ivreg2 fconflict_initiation gattwto democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear _i* (democracy_aid = l.donor_gdp  affinity_with_US) if polity2006!=-66&polity2006!=-77&year>=1990, first robust cluster(recipient_cowcode) redundant(affinity_with_US)
restore
gatt `ii' yfe*/
replace studynum = `ii' if _n==`ii'   
local ii=`ii'+1
*Model 4*
*Interaction - Multiple Stages*
#delimit ;
reg democracy_aid l.donor_gdp gattwto affinity_with_US 
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990;
#delimit cr
predict democracy_aidpred, xb
gen democracy_aidpredXdemoc32yr=democracy_aidpred*democratization

*model 3
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' orig
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990,  vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' noth
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' fe
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  year
if polity2006!=-66&polity2006!=-77&year>=1990,  vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' time
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr year
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' fet
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  i.ccode#c.year
if polity2006!=-66&polity2006!=-77&year>=1990, /* vce(boot, rep(1000) seed(2)) */;
#delimit cr
gatt `ii' ct
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear i.year 
if polity2006!=-66&polity2006!=-77&year>=1990, fe /* vce(boot, rep(1000) seed(2)) */;
#delimit cr
gatt `ii' cyfe
#delimit ;
xtreg fconflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, i(year) vce(boot, rep(1000) seed(2));
drop democracy_aidpred democracy_aidpredXdemoc32yr;
#delimit cr
gatt `ii' yfe

replace studynum = `ii' if _n==`ii'   
local ii=`ii'+1
***Table 4***
**Model 5**
*Any alliance type*
tsset recipient_cowcode year
#delimit ;
reg democracy_aid gattwto l.donor_gdp  affinity_with_US 
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear   
if polity2006!=-66&polity2006!=-77&year>=1990;
#delimit cr
predict democracy_aidpred, xb
gen democracy_aidpredXdemoc32yr=democracy_aidpred*democratization

*model 4
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' orig
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990,  vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' noth
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' fe
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr year
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990,  vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' time
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr year
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' fet
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr i.ccode#c.year
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990,  /*vce(boot, rep(1000) seed(2)) */;
#delimit cr
gatt `ii' ct
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear i.year 
if polity2006!=-66&polity2006!=-77&year>=1990, fe /* vce(boot, rep(1000) seed(2)) */;
#delimit cr
gatt `ii' cyfe
#delimit ;
xtreg fconflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US1 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, i(year) vce(boot, rep(1000) seed(2));
drop democracy_aidpred democracy_aidpredXdemoc32yr;
#delimit cr
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
local ii=`ii'+1
**Model 6**
*US Defense Pact*
tsset recipient_cowcode year
#delimit ;
reg democracy_aid l.donor_gdp  gattwto affinity_with_US 
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear   
if polity2006!=-66&polity2006!=-77&year>=1990;
#delimit cr
predict democracy_aidpred, xb
gen democracy_aidpredXdemoc32yr=democracy_aidpred*democratization

*model 5
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' orig
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' noth
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' fe
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr year
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990,  vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' time
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr year
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, fe vce(boot, rep(1000) seed(2));
#delimit cr
gatt `ii' fet
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr i.ccode#c.year
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, /* vce(boot, rep(1000) seed(2)) */;
#delimit cr
gatt `ii' ct
#delimit ;
xtreg f.conflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear i.year 
if polity2006!=-66&polity2006!=-77&year>=1990, fe /* vce(boot, rep(1000) seed(2)) */;
#delimit cr
gatt `ii' cyfe
#delimit ;
xtreg fconflict_initiation gattwto democracy_aidpred democracy_aidpredXdemoc32yr
democratization democracy growth_real_gdppc real_gdppc population alliance_with_US2 conflict_prioryear  
if polity2006!=-66&polity2006!=-77&year>=1990, i(year) vce(boot, rep(1000) seed(2));
drop democracy_aidpred democracy_aidpredXdemoc32yr;
#delimit cr
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
local ii=`ii'+1

replace study = "Savun Tirone" if studynum~=. 	

keep study-timetrend
drop if studynum==.
compress
save savuntirone.dta , replace


